package com.ybxx.fees.model;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.StringUtils;

import com.ybxx.core.model.BaseModel;

@Entity
@Table(name="tbl_fees_other_record")
public class OtherRecord extends BaseModel {
	@Id
	private String orcode;
	@ManyToOne(targetEntity=Records.class,fetch=FetchType.LAZY)
	@JoinColumn(name="frcode",referencedColumnName="frcode") 
	private Records records;
	private String combined;
	@OneToMany(targetEntity=OtherRecordItem.class,cascade={CascadeType.ALL},mappedBy="otherRecord",fetch = FetchType.LAZY)
	private Set<OtherRecordItem> items=new HashSet<OtherRecordItem>();
	@Transient
	private List<OtherRecordItem> itemsList=new ArrayList<OtherRecordItem>();
	public String getOrcode() {
		return orcode;
	}
	public void setOrcode(String orcode) {
		this.orcode = orcode;
	}
	public Records getRecords() {
		return records;
	}
	public void setRecords(Records records) {
		this.records = records;
	}
	public String getCombined() {
		return combined;
	}
	public void setCombined(String combined) {
		if(StringUtils.isNotEmpty(combined)){
			this.combined = combined;
		}
	}
	public Set<OtherRecordItem> getItems() {
		return items;
	}
	public void setItems(Set<OtherRecordItem> items) {
		this.items = items;
	}
	public List<OtherRecordItem> getItemsList() {
		this.items.addAll(itemsList);
		return itemsList;
	}
	
	
}
